<script setup lang="ts">
import { onMounted } from 'vue';

import TagTreeSelect from './tree-select.vue';

const emit = defineEmits(['change', 'close']);
const modelValue = defineModel<(number | string)[]>('value', {
  default: () => [],
});

function onChange(value: any) {
  emit('change', value);
}

onMounted(() => {
  if (modelValue.value === null) {
    modelValue.value = [];
  }
});
</script>

<template>
  <TagTreeSelect
    v-model:value="modelValue"
    :tag-type="2"
    @change="onChange"
    @close="emit('close')"
  />
</template>
